﻿using FastColoredTextBoxNS;
using System.Collections.Generic;
using System.Text.RegularExpressions;


namespace MPE
{
    static class AutoCompleete
    {
        static AutocompleteMenu popupMenu;

        public static void setTimer(int ms) { if (popupMenu != null) popupMenu.AppearInterval = ms; }
        public static void Init(FastColoredTextBox field)
        {
            popupMenu = new AutocompleteMenu(field) { AllowTabKey = true, MinimumSize = new System.Drawing.Size(300, 0), AppearInterval = 1, MinFragmentLength = 1, SearchPattern = @"\w" };

            List<AutocompleteItem> items = new List<AutocompleteItem>();

            foreach (var item in declarationSnippets)
                items.Add(new DeclarationSnippet(item));

            popupMenu.Items.SetAutocompleteItems(items);//set as autocomplete source
        }

        class DeclarationSnippet : SnippetAutocompleteItem
        {// This item appears when any part of snippet text is typed
            public DeclarationSnippet(string snippet) : base(snippet) { }
            public override CompareResult Compare(string fragmentText) => Regex.IsMatch(Text, "\\b" + Regex.Escape(fragmentText), RegexOptions.IgnoreCase) ? CompareResult.Visible : CompareResult.Hidden;
        }
        static readonly string[] declarationSnippets = {
            "$GLOBAL_LOGIN^",
            "$GLOBAL_EMAIL^",
            "$GLOBAL_PASS^",
            "$GLOBAL_NAME^",
            "$GLOBAL_WMID^",
            "$GLOBAL_WMR^",
            "$GLOBAL_WMZ^",
            "$GLOBAL_PAYPAL^",
            "$GLOBAL_PAYEER^",
            "$GLOBAL_PERFECT_MONEY^",
            "$GLOBAL_BITCOIN_WALLET^",
            "$GLOBAL_BCH_WALLET^",
            "$GLOBAL_DASH_WALLET^",
            "$GLOBAL_DOGECOIN_WALLET^",
            "$GLOBAL_ETHEREUM_WALLET^",
            "$GLOBAL_LITECOIN_WALLET^",
            "$GLOBAL_RUCAPTCHA_KEY^",
            "$_GLOBAL_1^",
            "$_GLOBAL_2^",
            "$GLOBAL_CAPMONSTER_IP^",
            "$GLOBAL_CAPMONSTER_KEY^",
            "$SIZE_BUFFER^",
            "$MODEL_NAME^",
            "[CLEAR_BUFFER]^",
            "$captcha^",
            "$bool^",
            "$WORK_TIME^",
            "$result^",
            "$REQUEST_DATA^",
            "$resultencode^",
            "$resultdecode^",
            "$count^",
            "$_GLOBAL_SERVER_PORT^",
            "$_TEMPLATE_ID^",
            "HTTP^",
            "HTTPS^",
            "REPORT^",
            "CONNECT^",
            "NUMBER^",
            "CHAR^",
            "UPPER_CHAR^",
            "ERROR_EXIT^",
            "ERROR_REPEAT^",
            "ERROR_CONTINUE^",
            "UNLOCK^",
            "[DISPLAY][^]",
            "[LOG_DISPLAY][^]",
            "[DISPLAY_BUFFER]^",
            "[DISPLAY_REQUEST]^",
            "[PARSE][^][]",
            "[REG_PARSE][^]",
            "[TO_BASE64][^]",
            "[FIND_TEXT][^]",
            "[FROM_BASE64][^]",
            "[URL_ENCODE][^]",
            "[URL_DECODE][^]",
            "[HASH][^][]",
            "[GET][^]",
            "$gen_pass^",
            "[GEN_PASSWORD][^][]",
            "[ADD_IN_BUFFER][^][]",
            "[SPLIT_STR][^][]",
            "[GET_CHAR][^][]",
            "[UPP_LOW_STR][^][]",
            "[STR_REPLACE][^][]",
            "[COMPARE_WITH_BUFFER][^]",
            "[RAND][^][]",
            "[STR_LEN][^]",
            "[SORT_BUFFER]^",
            "[TRIMMED][^]",
            "[CLEAR_REQUEST]^",
            "[STR_TO_UTF8][^]",
            "[OPERATIONS_WITH_BUFFERS][^]",
            "[IF][^]\n\n[ENDIF]",
            "[IF][^]\n\n[ELSE]\n\n[ENDIF]",
            "[VAR][^][]",
            "[INCLUDE][^]",
            "[IF][^]",
            "$IT^",
            "[IS_NUMERIC][^]",
            "[ELSE]^",
            "[ENDIF]^",
            "[BREAK_POINT][^]",
            "[GO_TO_BREAK_POINT][^]",
            "[PLAY_SOUND][^]",
            "[EXIT_TASK]^",
            "[REPEAT_TASK]^",
            "[VERSION][1][VPATH^]",
            "[SLEEP][^]",
            "[SET_MODEL_SETTINGS][^]",
            "[SET_INCOM][^]",
            "[CBROWSER_COMMAND][^][][]",
            "SecsSinceEpoch^",
            "[EVALUATE_JS][JS]\n^\n[/JS]",
            "[EVALUATE_JS][^]",
            "[JS]^",
            "^[/JS]",
            "[USE_BUFFER][^]",
            "[CLEAR_TEMPLATE_MEMORY]^",
            "[EXEC_SQL][^][]",
            "[MUTEX][1^][]",
            "[MATH][^]",
            "MAX_BUFFER_SIZE^",
            "MAX_BREAK_POINT_CYCLE^",
            "[STATIONARY_CBROWSER_COMMAND][^][]",
            "[GDATE][^]",
            "[WRITE_IN_FILE][^][]",
            "[ADD_TO_FILE][^][]",
            "[READ_FILE_ALL][^]",
            "[READ_FILE_LINE][^]",
            "[WRITE_BUFFER_IN_FILE][^]",
            "[SAVE_CLEAR_REQUEST][^]",
            "[DELETE_FILE][^]",
            "[COPY_FILE][^][]",
            "[RENAME_FILE][^][]",
            "[MOVE_FILE][^][]",
            "[FILE_EXISTS][^]",
            "[CREATE_DIR][^]",
            "[DELETE_DIR][^]",
            "[COPY_DIR][^][]",
            "[RENAME_DIR][^][]",
            "[FOLDER_EXISTS][^]",
            "[FROM_BASE64_TO_FILE][^][]",
            "[FROM_FILE_TO_BASE64][^]",
            "[READ_BINARY_LINE_FILE][^][]",
            "[CREATE_BINARY_LINE_FILE][^]",
            "[FIND_IN_BINARY_LINE_FILE][^][]",
            "[COUNT_LINE_IN_BINARI_FILE][^]",
            "[OPEN_URL_IN_LOCAL_BROWSER][^]",
            "[RUN_FILE][^]",
            "[LOAD_CAPTCHA][^]",
            "[SAVE_CAPTCHA]^",
            "[CONVERT_IMG][^][]",
            "[GET_IMAGE_FROM_ARRAY_IMG][^]",
            "[DELL_IMAGE_FORM_ARRAY_IMG][^]",
            "[SET_IMAGE_TO_ARRAY_IMG][^]",
            "[ARRAY_TO_IMAGE][^]",
            "[SPLIT_BLACK_END]^",
            "[SPLIT_CIRCUIT]^",
            "[SPLIT_WIDTH][^]",
            "[SPLIT_SHADES]^",
            "[SPLIT_CIRCUIT_EX][^]",
            "[SPLIT_SHADES_EX][0^]",
            "[SET_SPLIT_EX_FILTER][^][]",
            "[DISPLAY_IMG]^",
            "[DISPLAY_ARRAY_IMG]^",
            "$IMG_ARRAY_COUNT^",
            "[COMPARE_IMAGES][^][]",
            "[GET_IMAGE_INFO][^]",
            "[ENTER_CAPTCHA][^]",
            "[CLEAR_TRANSPARENT]^",
            "[COLOR_TRESHOLD][128^]",
            "[CLEAR_INTERFERENCE][^]",
            "[CHANGE_COLOR_IF_NOT_THIS_COLOR][^][]",
            "[CLEAR_GRADIENT]^",
            "[CLEAR_LINES][^]",
            "[APPLY_NEGATIVE]^",
            "[SEAL_MICROCRACKS][^]",
            "[RGB_COLOR_TRESHOLD][^][]",
            "[CHANGE_COLOR_ON_COLOR][^][]",
            "[FIND_PIXEL][^]",
            "[ONE_OF_RGB_TO_BLACK]^",
            "[ALIGN_IMG][^]",
            "[ALIGN_IMG_ARRAY][^]",
            "[CROP][^][]",
            "[CROP_ALL_SIDE]^",
            "[COPY_IMAGE][^]",
            "[CUT_GRID][4:5^]",
            "[COMPRESS_SHADES][^]",
            "[START_MAKE_MODEL]^",
            "[END_MAKE_MODEL]^",
            "[COMPLETE_MAKE_MODEL][$MODEL_NAME^]",
            "[FIND_ARRAY_IMG_IN_MODEL_LIST][^]",
            "[RUCAPTCHA][^][]",
            "[CAPTCHA_PROEVOLITION][^]",
            "[TESSERACT][$MODEL_NAME_captcha.png^]",
            "[ABBYY_READER][^]",
            "[LOCAL_QUEUE_POP]^",
            "[LOCAL_QUEUE_PUSH][^]",
            "[LOCAL_QUEUE_CLEAR]^",
            "[LOCAL_QUEUE_SIZE]^",
            "[LOCAL_QUEUE_PUSH_BUFFER]^",
            "[GLOBAL_QUEUE_POP]^",
            "[GLOBAL_QUEUE_PUSH][^]",
            "[GLOBAL_QUEUE_CLEAR]^",
            "[GLOBAL_QUEUE_SIZE]^",
            "[GLOBAL_QUEUE_PUSH_BUFFER]^",
            "[LOAD_COOKIE]^",
            "[LOGICAL_READER]^",
            "[FIND_IMG_LIST_ON_IMG][^][]",
            "RECAPTCHA_RESPONSE^",
            "[RECAPTCHA_READER][^]",
            "[XEVIL][^][]",
            "[POST][^][]",
            "[PUT][^][]",
            "[POST_MULTIPART][^][][]",
            "[PASS_CLOUDFLARE][^]",
            "[AJAX_GET][^]",
            "[AJAX_POST][^][]",
            "[AJAX_PUT][^][]",
            "[SET_USER_AGENT][^]",
            "[SET_REFERER][^]",
            "[SET_HOST][^][]",
            "[COOKIE_TO_BUFFER][^]",
            "[SET_TIMEOUT][^]",
            "[REQUEST_TO_UTF]^",
            "[SET_COOKIE][^][]",
            "[CLEAR_ALL_COOKIES]^",
            "[COPY_COOKIE][^][]",
            "[SAVE_COOKIE]^",
            "[ADD_HEADER][^][]",
            "[ADD_TEMPORARY_HEADER][^][]",
            "[DELL_ADDED_HEADER][^]",
            "[CLEAR_ADDED_HEADERS]^",
            "[SET_KEEP_ALIVE][^][]",
            "[USE_PROXY][^][]",
            "[DELL_PROXY]^",
            "[SET_PHP_GATE][^]",
            "[UNSET_PHP_GATE]^",
            "[TOR_NEW_IDENTITY][^]",
            "[ON_OFF_PROXY][^]",
            "[IMAP_COMMAND][^][][]",
            "WRITE_WORK_LOG_IN_FILE^",
            "RED^",
            "BLUE^",
            "GREEN^",
            "FILTER_MAX_WIDTH^",
            "FILTER_MAX_HEIGHT^",
            "FILTER_MIN_WIDTH^",
            "FILTER_MIN_HEIGHT^",
            "SET_FIXED_WIDTH^",
            "VERTICAL^",
            "HORISONTAL^",
            "[TO_FIXED][^][]",
            "TOP^",
            "DOWN^",
            "LEFT^",
            "RIGHT^",
            "READ_UNSEEN_LETTER^",
            "SPECIAL_CHAR^",
            "SOCKS5^",
            "SET_NULL^",
            "$TIME^",
            "$DATE^",
            "AUTO_REDIRECT^",
            "LOCK^",
            "START_BROWSER^",
            "SHOW_NORMAL^",
            "SHOW_MINIMAZE^",
            "CLOSE_WINDOW^",
            "OPEN_URL^",
            "WAIT_LOAD^",
            "GET_URL^",
            "EVAL_JS^",
            "MOUSE_EMULATION^",
            "SCREEN_SHOT^",
            "LBUTTON_CLICK^",
            "RBUTTON_CLICK^",
            "MOUSE_WHEEL^",
            "LBUTTON_PRESS^",
            "LBUTTON_RELEASE^",
            "MOUSE_MOVE^",
            "IS_LOAD^",
            "SET_PROXY^",
            "SET_WINDOW_SIZE^",
            "SET_POSITION^",
            "SET_USERAGENT^",
            "ACTION^",
            "START^",
            "TABS^",
            "LOAD^",
            "URL^",
            "JS^",
            "SCRIPT^",
            "GET_COOKIES^",
            "url^",
            "domain^",
            "name^",
            "INFO^",
            "DELL_PROXY^",
            "CHECK^",
            "CLOSE^",
            "standart^",
            "invisible^",
            "IP^",
            "HOST^",
            "TYPE^",
            "USER^",
            "[PARSE_JSON][^][]",
            "PASS^",
            "SAIT^",
            "KEY^",
            "RECAPTCHA^",
            "[COPY_TO_CLIPBOARD][^]",
            "[DELETE][^]",
            "[STR_MID][^][]",
            "[FLOOR][^][]",                 
            "$current_path^",
            
            
            
/*Функции для браузере OpenMBFR*/
            "https^",
            "socks5^",

            "TOR^",
            "DEL_TOR^",

            "IS_JS^",
            "ENABLE_JS^",
            "DISABLE_JS^",

            "SCROLL_Y^",
            "SCROLL_TO_Y^",
            "SCROLL_Y_POSITION^",
            "SCROLL_Y_MAX^",

            "SCROLL_X^",
            "SCROLL_TO_X^",
            "SCROLL_X_POSITION^",
            "SCROLL_X_MAX^",

            "TOPMOST^",

            "WINDOW_MAXIMIZED^",
            "ENABLE_ACCELERATION^",
            "DISABLE_ACCELERATION^",
            "DELETE_ALL_COOKIES^",
            "SET_CACHE_DIR^",
            "SET_COOKIE_DIR^",
            "SET_OWN_CACHE_DIR^",
            "SET_OWN_COOKIE_DIR^",
            "SET_WINDOW_TITLE^",
            "SAVE_COOKIES^",
            "SAVE_COOKIES_TO_PATH^",
        };
    }
}
